<template>
	<view>
		<block v-if="!share">
			<!-- #ifdef MP-DINGTALK  -->
			<u-navbar :title="title" :border="border" :leftIconSize="autoBack && !hideBackIcon ? '20px' : '0'" placeholder :autoBack="preventBack"
				@leftClick="leftClick" />
			<!-- #endif -->
			<!-- #ifndef MP-DINGTALK -->
			<u-navbar :border="border" :height="navHeight.navigationCustomCapsuleHeight" :title="title" :leftIconSize="autoBack &&!hideBackIcon ? '20px' : '0'" placeholder :autoBack="preventBack"
				@leftClick="leftClick" />
			<!-- #endif -->
		</block>
		<block v-else>
			<!-- #ifdef MP-DINGTALK  -->
			<u-navbar :border="border" :leftIconSize="autoBack&& !hideBackIcon ?'20px':'0'" placeholder>
				<view class="u-nav-slot" slot="left">
					<u-icon name="home" size="24" @click="toHome"></u-icon>
				</view>
			</u-navbar>
			<!-- #endif -->
			<!-- #ifndef MP-DINGTALK -->
			<u-navbar :border="border" :height="navHeight.navigationCustomCapsuleHeight" :title="title" :leftIconSize="autoBack&& !hideBackIcon ? '20px':'0'" placeholder>
				<view class="u-nav-slot" slot="left">
					<u-icon name="home" size="24" @click="toHome"></u-icon>
				</view>
			</u-navbar>
			<!-- #endif -->
		</block>
	</view>
</template>

<script>
	import {computesNavHeight } from "../utils/util.js"
	export default {
		// props: ["autoBack", "title", "share"],
		props:{
			autoBack:{
				default:true,
				type:Boolean
			},
			title:{
				default:"",
				type:String
			},
			share:{
				default:false,
				type:Boolean
			},
			preventBack:{
				default:true,
				type:Boolean
			},
			showBottom:{
				default:true,
				type:Boolean
			},
			border: {
				type: Boolean,
				default: () => true
			}
			
		},
		data() {
			return {
				hideBackIcon: false,
				navHeight: 0,
			};
		},
		computed: {
			systemInfo() {
				return this.$store.state.system.infos;
			}
		},
		mounted() {
			this.hideBackIcon = this.systemInfo.hideBackIcon;
			this.navHeight = computesNavHeight()
		},
		methods: {
			leftClick() {
				this.$emit("leftClick");
			},
			toHome() {
				console.log("home")
				uni.navigateTo({
					url: '/pages/index/index'
				})
			}
		}
	};
</script>

<style>
	/deep/ .u-navbar{
		width: 100%;
	}
</style>
